<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title><!--{$lang.page.index.title}--></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-body">
            <table id="datalist" class="layui-table" lay-filter="datalist"></table>
            <script type="text/html" id="toolbartop">
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-sm add muetool"><!--{$lang.page.public.add}--></button>
                </div>
            </script>
            <script type="text/html" id="bartool">
                <a class="layui-btn layui-btn-xs edit" data-set="{{d.id}}"><!--{$lang.page.public.edit}--></a>
                <a class="layui-btn layui-btn-danger layui-btn-xs del" data-set="{{d.id}}"><!--{$lang.page.public.del}--></a>
            </script>
        </div>
    </div>
</div>

<script src="/static/lay/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
       base: '/static/lay/' //静态资源所在路径
    }).extend({
        treetable: 'lib/treetable-lay/treetable' //主入口模块
        , roleper:'lib/roleper'
        , xadmin:'lib/xadmin'
        , lang:'lib/lang'
         }).use(['jquery','layer', 'table', 'treetable', 'roleper', 'xadmin','lang'], function () {

                var $ = layui.$
                , form = layui.form
                , table = layui.table
                , layer = layui.layer
                , treetable = layui.treetable
                , roleper = layui.roleper
                , toolbar = roleper.showtool({mid:2}) ? false : true; //根据权限是否显示操作列
                var lang=layui.lang.init();
                // 渲染表格
                var renderTable = function() { 
                    layer.load(2);
                    treetable.render({
                        treeColIndex: 0, //树形图标显示在第几列
                        treeSpid: 0, //最上级的父级id
                        treeIdName: 'id', //id字段的名称
                        treePidName: 'pid', //pid字段的名称
                        treeDefaultClose: true, //是否默认折叠
                        treeLinkage: false, //父级展开时是否自动展开所有子级
                        elem: '#datalist',
                        url: 'data',
                        page: false,
                        toolbar: '#toolbartop', 
                        defaultToolbar: ['filter', 'exports', 'print'], 
                        cols: [
                            [{
                                field: 'id',
                                title: 'ID',
                                align: "center",
                                fixwidth: true,
                                width: 120,

                            }, {
                                field: 'title',
                                // title: '模块名称',
                                title: function(){ return lang.name },
                                templet: function(d) {
                                    if (d.icon) {
                                        return d.strsign+'<i class="layui-icon">&#'+d.icon+'</i>'+d.title;
                                    } else {
                                        return d.strsign+d.title;
                                    }
                                }
                            }, {
                                field: 'orderid',
                                title: function(){ return lang.sort },
                                align: "center"
                            }, {
                                field: 'code',
                                title: function(){ return lang.ident },
                                // align: "center"

                            }, {
                                field: 'url',
                                title: function(){ return lang.entryurl },
                                // align: "center"

                            }, {
                                field: 'is_menu',
                                title: function(){ return lang.topmue },
                                 templet: function(d) {
                                    if (d.is_top == 1) {
                                        return '<button class="layui-btn layui-btn-xs">'+lang.yes+'</button>';
                                    } else {
                                        return '<button class="layui-btn layui-btn-primary layui-btn-xs">'+lang.no+'</button>';
                                    }
                                }
                            }, {
                                field: 'level',
                                title: function(){ return lang.muelevel },
                                // align: "center",
                                fixwidth: true,
                                // width: 200,
                                templet: function(d) {
                                    if (d.level == 0) {
                                        return lang.higtestmue;
                                    } else {
                                        return d.clevel+lang.muelev;
                                    }
                                }
                            },{
                                field: 'status',
                                title: function(){ return lang.status },
                                align: "center",
                                templet: function(d) {
                                    if (d.status == 1) {
                                        return '<button class="layui-btn layui-btn-xs">'+lang.normal+'</button>';
                                    } else {
                                        return '<button class="layui-btn layui-btn-primary layui-btn-xs">'+lang.close+'</button>';
                                    }
                                }
                            },{
                                fixed: '', 
                                title: function(){ return lang.operation }, 
                                // width: 160, 
                                align: 'center', 
                                toolbar: '#bartool',
                                hide: toolbar
                            }]],
                        done: function() {
                            layer.closeAll('loading');
                            roleper.render({mid:2,per:[{sys:'add',method:'open'},{sys:'edit',method:'open'},{sys:'del',method:'del'}],law:'1080*600',par:false,offset:'20px'});//law 设置长宽，full是否全屏，par父窗口打开
                        }
                    });
                };
                renderTable();
    });
</script>
</body>
</html>

